package arch.chameleon.module.web.bind;

import java.util.Map;

import javax.servlet.ServletRequest;

import org.springframework.beans.MutablePropertyValues;
import org.springframework.util.Assert;

import arch.chameleon.support.constants.WebConstants;

/**
 * 通过ServletRequest获取Attribute值来创建PropertyValues
 * 
 * @author George
 *
 */
public class ServletRequestBodyPropertyValues extends MutablePropertyValues {

	private static final long serialVersionUID = -8403344247409817081L;
	
	public ServletRequestBodyPropertyValues(ServletRequest request) {
		super(getBodyAttributes(request));
	}
	
	/**
	 * 从request的Body中获取上送属性集
	 * @param request 
	 * @return
	 */
	private static Map<String, Object> getBodyAttributes(ServletRequest request){
		Assert.notNull(request, "Request must not be null");
		return (Map)request.getAttribute(WebConstants.REQ_BODY);
	}
}


